//
//  FLMRegisterVC.m
//  FLMSuperSOS
//
//  Created by xiaoyang on 16/9/5.
//  Copyright © 2016年 GuangzhouFaLaoMiaoNetworkTechnologyCo. All rights reserved.
//

#import "FLMRegisterVC.h"

#import "FLMForgetPasswordVC.h"
#import "FLMLoginVC.h"

@interface FLMRegisterVC (){
    
    UIScrollView * scr;
    UITextField * usernameText,*passwordText,*aginpasswordText,*valiteText;
    
    UIImageView * img1,*img2,*img3,*img4;
    
    UILabel * tipLable1,*tipLable2;
}

@end

@implementation FLMRegisterVC
- (void)viewDidLoad {
    [super viewDidLoad];
    
    scr=[LSF_Util add_scollview:CGRectMake(0, 64, ScreenW, ScreenH-64) Tag:1 View:self.view co:CGSizeMake(0, ScreenH)];
    
    //用户名
    [LSF_Util labelName:@"登录账号" fontSize:14.0f rect:CGRectMake(20, 30,60, 30) View:scr Alignment:0 Color:black Tag:1];
    usernameText=[LSF_Util addTextFieldView:CGRectMake(90, 30, ScreenW-130, 30) Tag:1 textColor:black Alignment:0 Text:nil placeholderStr:@"手机号或邮箱" View:scr font:14.0f];
    [usernameText addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    img1=[LSF_Util addSubviewImage:@"register2" rect:CGRectMake(ScreenW-30, 37, 16, 16) View:scr Tag:1];
    tipLable1=[LSF_Util labelName:@"输入出错" fontSize:12.0f rect:CGRectMake(0, 60, ScreenW-10, 20) View:scr Alignment:2 Color:[UIColor redColor] Tag:1];
    [LSF_Util setXianTiao:ColorHUI rect:CGRectMake(90, 60, ScreenW-130, 1) view:scr];
    
    
    //第一次输入密码
    [LSF_Util labelName:@"密码" fontSize:14.0f rect:CGRectMake(20, 80,60, 30) View:scr Alignment:0 Color:black Tag:1];
    passwordText=[LSF_Util addTextFieldView:CGRectMake(90, 80, ScreenW-130, 30) Tag:2 textColor:black Alignment:0 Text:nil placeholderStr:@"请输入密码" View:scr font:14.0f];
    [passwordText addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    img2=[LSF_Util addSubviewImage:@"register2" rect:CGRectMake(ScreenW-30, 87, 16, 16) View:scr Tag:1];
    
    [LSF_Util setXianTiao:ColorHUI rect:CGRectMake(90, 110, ScreenW-130, 1) view:scr];
    
    
    //在次输入密码
    [LSF_Util labelName:@"确认密码" fontSize:14.0f rect:CGRectMake(20, 130,60, 30) View:scr Alignment:0 Color:black Tag:1];
    aginpasswordText=[LSF_Util addTextFieldView:CGRectMake(90, 130, ScreenW-130, 30) Tag:3 textColor:black Alignment:0 Text:nil placeholderStr:@"再次请输入密码" View:scr font:14.0f];
    [aginpasswordText addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    img3=[LSF_Util addSubviewImage:@"register2" rect:CGRectMake(ScreenW-30, 137, 16, 16) View:scr Tag:1];
    
    tipLable2=[LSF_Util labelName:@"" fontSize:12.0f rect:CGRectMake(0, 160, ScreenW-10, 20) View:scr Alignment:2 Color:[UIColor redColor] Tag:1];
    
    
    [LSF_Util setXianTiao:ColorHUI rect:CGRectMake(90, 160, ScreenW-130, 1) view:scr];
    
    
    //验证码
    [LSF_Util labelName:@"验证码" fontSize:14.0f rect:CGRectMake(20, 180,60, 30) View:scr Alignment:0 Color:black Tag:1];
    valiteText=[LSF_Util addTextFieldView:CGRectMake(90, 180, 100, 30) Tag:4 textColor:black Alignment:0 Text:nil placeholderStr:@"请输入验证码" View:scr font:14.0f];
    [valiteText addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    img4=[LSF_Util addSubviewImage:@"register2" rect:CGRectMake(210, 187, 16, 16) View:scr Tag:1];
    
    [LSF_Util setXianTiao:ColorHUI rect:CGRectMake(90, 210,100, 1) view:scr];
    
    
    //注册按钮
    UIButton * registerBtn= [LSF_Util buttonPhotoAlignment:@"registerWhite" hilPhoto:@"registerHight" rect:CGRectMake(50, 240, ScreenW-100, 35) title:nil Tag:1 View:scr textColor:orange Size:font14 backgroundColor:MS_RGBA(242, 242, 242, 0.7)];
    [registerBtn addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
    
    //超级登陆img
    [LSF_Util addSubviewImage:@"login1" rect:CGRectMake((ScreenW-347/2)/2,300, 374/2, 203/2) View:scr Tag:1];
    
    
    [LSF_Util labelName:@"为您得生活提供更优惠得福利,为您得生活精打细算" fontSize:13.0 rect:CGRectMake(0,300+203/2+20,ScreenW,40) View:scr Alignment:1 Color:gray Tag:1];
}

-(void)textFieldDidChange:(UITextField *)textField
{
    NSLog(@"%@",textField.text);
    
    if(textField.tag==1){
        
        if(usernameText.text.length>=6){
            img1.image=[UIImage imageNamed:@"register1"];
            tipLable1.text=@"";
        }else{
            
            img1.image=[UIImage imageNamed:@"register2"];
            tipLable1.text=@"输入出错";
        }
    }
    
    if(textField.tag==2){
        
        if(passwordText.text.length>=6){
            img2.image=[UIImage imageNamed:@"register1"];
        }else{
            
            img2.image=[UIImage imageNamed:@"register2"];
        }
    }
    
    if(textField.tag==3){
        
        if([passwordText.text isEqual:aginpasswordText.text]){
            img3.image=[UIImage imageNamed:@"register1"];
            tipLable2.text=@"";
            
        }else{
            
            img3.image=[UIImage imageNamed:@"register2"];
            tipLable2.text=@"两次输入密码不相同";
            
        }
    }
    
    if(textField.tag==4){
        
        //这个需要接口来配合,你输入的参数跟接口返回的对比，如果一样img4就变成打勾状态，如果不一样img4叉叉状态，并重新调用接口来获取验证码
    }
    
}

#pragma mark --------------------
#pragma mark 设置导航栏
- (void)viewWillAppear:(BOOL)animated
{
    //设置导航栏上的左边item
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(leftItem) image:@"navigationButtonReturn" hightImage:@"navigationButtonReturnClick"];
    
    //设置导航栏上的又边item
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTitle:@"登录" target:self action:@selector(actNavRightBtn)];
    
    //设置标题
    self.navigationItem.title = @"登录";
    //设置标题颜色
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor blackColor]};
}


#pragma mark --------------------
#pragma mark 左边item
- (void)leftItem
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

//登陆按钮触发
-(void)actNavRightBtn{
    
    FLMLoginVC * login =[[FLMLoginVC alloc] init];
    [self.navigationController pushViewController:login animated:YES];
}

//注册按钮触发
-(void)registerAction{
    
    NSLog(@"注册完成");
    
    
}

@end
